﻿@model Doan.Forum.Models.Category
@using Ext.Net
@using Ext.Net.MVC
@{
    ViewBag.Title = "Edit Category";
    Layout = "~/Views/Shared/_Layout_Admin.cshtml";
}

@section Header
{
}
@section ToolbarSection{
    @Html.X().Button().Text("Save").ID("btnSave").Disabled(true).Icon(Icon.Disk).DirectEvents(de =>
            {
                de.Click.Url = Url.Action("EditCategory");
                de.Click.EventMask.ShowMask = true;
                de.Click.FormID = "FormPanelEditCategory";
            })
    
    @Html.X().Button().Text("Back").Icon(Icon.ArrowLeft).Margins("0 0 0 10").Listeners(ls => ls.Click.Handler = "window.parent.location.reload();parentAutoLoadControl.close();")
}

@Html.X().FormPanel().ID("FormPanelEditCategory").Title("Edit Category").StyleSpec("position: static; z-index: 10;width: 100%;").AutoScroll(true).Listeners(
ls => ls.ValidityChange.Handler = "App.btnSave.setDisabled(!valid)").Items(
        Html.X().HiddenFor(m=>m.CategoriId),
        Html.X().ComboBoxFor(m => m.ParentId).FieldLabel("ParentCategory").SelectedItems(Model.ParentId.ToString()).LabelWidth(130).Items(ViewBag.ParentId).Width(400).StyleSpec("Margin: 15px 0px 0px 100px"),
        Html.X().TextFieldFor(m => m.CategoryName).Width(800).LabelWidth(130).StyleSpec("Margin: 15px 0px 0px 100px"),
        Html.X().HtmlEditorFor(m=>m.Description).Width(800).LabelWidth(130).StyleSpec("Margin: 15px 0px 0px 100px"),
        Html.X().TextFieldFor(m=>m.SortOrder).Width(400).LabelWidth(130).StyleSpec("Margin: 15px 0px 0px 100px"),
        Html.X().FileUploadField().FieldLabel("Image").ID("UpImage").Value(Model.Logo).Icon(Icon.ImageAdd).Width(400).LabelWidth(130).StyleSpec("Margin: 15px 0px 0px 100px"),
        Html.X().Image().Height(150).Width(150).StyleSpec("Margin: 15px 0px 0px 500px").ImageUrl("../.."+ Model.Logo),
        Html.X().CheckboxFor(m=>m.Active).LabelWidth(130).StyleSpec("Margin: 15px 0px 0px 100px").Flex(1)
)